<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title>insert - Database - Prails API Documentation</title>
    </head>
    <body>
        <h3 class="P4"><a name="_InsertQuery"><span/></a>insert</h3><h4 class="Heading_20_4"><a name="_Description_"><span/></a>Description:</h4>
        <p class="Text_20_body">
            inserts a tupel into the specified table and returns the ID of the new entry.
        </p>
        <h4 class="Heading_20_4"><a name="_Syntax_"><span/></a>Syntax:</h4>
        <p class="Text_20_body">
            <code>Integer insert($str_table, $arr_data)</code><br/>
            <code>Integer ins($str_table, $arr_data)</code><br/>
            <code>Integer add($str_table, $arr_data)</code><br/>
            <code>Integer set($str_table, $arr_data)</code>
        </p>
        <table border="0" cellspacing="0" cellpadding="0" class="Table14">
            <colgroup>
                <col width="126"/><col width="617"/>
            </colgroup>
            <tr>
                <td style="text-align:left;width:2.882cm; " class="Table14_A1">
                    <p class="Table_20_Contents">
                        $str_table
                    </p>
                </td>
                <td style="text-align:left;width:14.116cm; " class="Table14_B1">
                    <p class="Table_20_Contents">
                        The table's name the tupel should be inserted into.
                    </p>
                </td>
            </tr>
            <tr>
                <td style="text-align:left;width:2.882cm; " class="Table14_A2">
                    <p class="Table_20_Contents">
                        $arr_data
                    </p>
                </td>
                <td style="text-align:left;width:14.116cm; " class="Table14_B2">
                    <p class="Table_20_Contents">
                        Data to be inserted. Only entries, whose key matches one of the table's field names, are actually taken into account.
                    </p>
                </td>
            </tr>
        </table>
        <p class="Text_20_body">The ins(), add() and set() methods are aliases for the insert() method.</p>
        <h4 class="Heading_20_4"><a name="_Example_"><span/></a>Example:</h4>
        <p class="Text_20_body">
            This example inserts a user into the <code>user</code> table.
        </p>
        <pre>
            $user_id = $this->add("user", Array(
                "first_name" => "Test",
                "last_name" => "User",
                "email" => "tester@example.org"
            ));
        </pre>
    </body>
</html>
